<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui" >

<head>

</head>
<body>


	<ui:composition template="../WEB-INF/layout/template.xhtml">
		<ui:define name="title"><h:outputText value="#{msg.add_student}" /></ui:define>
		<ui:define name="content">
		
			<div style="width:750px;margin:auto;">

				<h:form id="form">
				<p:panel id="panel">

					<fieldset>
						<legend><h:outputText value="#{msg.student_details}"/></legend>
						<small>(<h:outputText value="#{msg.mandatory_fields})"/></small>
									
							<fieldset id="generalities">
								<legend>#{msg.generalities}</legend>
								<h:panelGrid columns="3">
									<h:outputText value="#{msg.name} *: "/>
									<p:inputText id="nome" value="#{inserisciStudenteBean.studentInput.firstName}" required="true">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>
									</p:inputText>
									<p:message for="nome" style="color:red;"/>
					
									<h:outputText value="#{msg.surname} *: "/>
									<p:inputText id="cognome" value="#{inserisciStudenteBean.studentInput.surname}" required="true">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>
									</p:inputText>
									<p:message for="cognome" style="color:red;"/>
						
									<h:outputText value="#{msg.birth_date}: "/>
									<p:calendar id="dataNascita" value="#{inserisciStudenteBean.studentInput.dataNascita}"/>
									<p:message for="dataNascita" style="color:red;"/>
							
									<h:outputText value="#{msg.codice_fiscale}: "/>
									<p:inputText id="codiceFiscale" value="#{inserisciStudenteBean.studentInput.codiceFiscale}" >
										<f:validator validatorId="codiceFiscaleValidator" style="color:red;"/>
									</p:inputText>
									<p:message for="codiceFiscale" style="color:red;"/>
								</h:panelGrid>
							</fieldset>
					
							
								<fieldset>
									<legend>#{msg.emails}</legend>
									<h:dataTable id="emailTable" value="#{inserisciStudenteBean.studentInput.emails}" var="email">
										<h:column>
											<h:outputText value="#{msg.email}: "/>
										</h:column>
										<h:column>
											<p:inputText id="email" value="#{email.email}" required="true">
												<f:validateLength minimum="5" maximum="50"/>
												<f:validator validatorId="emailValidator"/>
											</p:inputText>
										</h:column>
										<h:column>
											<h:selectOneMenu value="#{email.type}">
												<f:selectItems value="#{inserisciStudenteBean.emailTypeOptions}"/>
											</h:selectOneMenu>
										</h:column>
										<h:column>
											<p:commandLink process="@this" value="#{msg.delete}" update="form:panel" action="#{inserisciStudenteBean.removeEmail}" >
												<f:setPropertyActionListener value="#{email}" target="#{inserisciStudenteBean.emailToRemove}" />
											</p:commandLink>
										</h:column>
										<h:column>
											<p:message for="email" style="color:red;"/>
										</h:column>
									</h:dataTable>
									<p:commandLink value="#{msg.add_email}" update="panel" action="#{inserisciStudenteBean.addEmptyEmail}"/>								
								</fieldset>
					
							<fieldset>
								<legend>#{msg.phones}</legend>
								<h:dataTable value="#{inserisciStudenteBean.studentInput.telephones}" var="telephone">
									<h:column>
										<h:outputText value="#{msg.number}: "/>
									</h:column>
									<h:column>
										<p:inputText id="number" value="#{telephone.number}" required="true">
											<f:validator validatorId="telefonoValidator"/>
										</p:inputText>
									</h:column>
									<h:column>
										<h:selectOneMenu value="#{telephone.type}">
											<f:selectItems value="#{inserisciStudenteBean.phoneTypeOptions}"/>
										</h:selectOneMenu>
									</h:column>
									<h:column>
										<h:selectOneMenu value="#{telephone.country}">
											<f:selectItems value="#{inserisciStudenteBean.phoneCountryOptions}"/>
										</h:selectOneMenu>
									</h:column>
									<h:column>
										<p:commandLink value="#{msg.delete}" process="@this" update="#{p:component('panel')}" action="#{inserisciStudenteBean.removeTelephone}" >
											<f:setPropertyActionListener value="#{telephone}" target="#{inserisciStudenteBean.telephoneToRemove}" />
										</p:commandLink>
									</h:column>
									<h:column>
										<p:message for="number" style="color:red;"/>
									</h:column>
								</h:dataTable>
								<p:commandLink value="#{msg.add_phone}" update="panel" action="#{inserisciStudenteBean.addEmptyPhone}"/>
							</fieldset>
							
							<fieldset>
								<legend>#{msg.faxes}</legend>
								<h:dataTable value="#{inserisciStudenteBean.studentInput.faxes}" var="fax">
									<h:column>
										<h:outputText value="#{msg.number}: "/>
									</h:column>
									<h:column>
										<p:inputText id="number" value="#{fax.number}" required="true">
											<f:validator validatorId="telefonoValidator"/>
										</p:inputText>
									</h:column>
									<h:column>
										<p:commandLink value="#{msg.delete}" process="@this" update="#{p:component('panel')}" action="#{inserisciStudenteBean.removeFax}" >
											<f:setPropertyActionListener value="#{fax}" target="#{inserisciStudenteBean.faxToRemove}" />
										</p:commandLink>
									</h:column>
									<h:column>
										<p:message for="number" style="color:red;"/>
									</h:column>
								</h:dataTable>
								<p:commandLink value="#{msg.add_fax}" update="panel" action="#{inserisciStudenteBean.addEmptyFax}"/>
							</fieldset>
					
							<fieldset>
								<legend>#{msg.it_address}</legend>
								<h:panelGrid columns="3">
									<h:outputText value="#{msg.address_line_1}: "/>
									<p:inputText id="indirizzoLinea1It" value="#{inserisciStudenteBean.studentInput.indirizzoIt.indirizzoLinea1}">
									</p:inputText>
									<p:message for="indirizzoLinea1It" style="color:red;"/>
				
									<h:outputText value="#{msg.address_line_2}: "/>
									<p:inputText id="indirizzoLinea2It" value="#{inserisciStudenteBean.studentInput.indirizzoIt.indirizzoLinea2}">
									</p:inputText>
									<p:message for="indirizzoLinea2It" style="color:red;"/>
				
									<h:outputText value="#{msg.town}: "/>
									<p:inputText id="cittaIt" value="#{inserisciStudenteBean.studentInput.indirizzoIt.citta}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>
									</p:inputText>
									<p:message for="cittaIt" style="color:red;"/>
				
									<h:outputText value="#{msg.province}: "/>
									<p:inputText id="provincia" value="#{inserisciStudenteBean.studentInput.indirizzoIt.provincia}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="provincia" style="color:red;"/>
					
									<h:outputText value="#{msg.cap}: "/>
									<p:inputText id="cap" value="#{inserisciStudenteBean.studentInput.indirizzoIt.cap}">
										<f:validator validatorId="capValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="cap" style="color:red;"/>
				
									<h:outputText value="#{msg.country}: "/>
									<p:inputText id="paeseIt" value="#{inserisciStudenteBean.studentInput.indirizzoIt.paese}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="paeseIt" style="color:red;"/>
								</h:panelGrid>
							</fieldset>
							
							<fieldset>
								<legend>#{msg.au_address}</legend>
								<h:panelGrid columns="3">
									<h:outputText value="#{msg.address_line_1}: "/>
									<p:inputText id="indirizzoLinea1Au" value="#{inserisciStudenteBean.studentInput.indirizzoAu.indirizzoLinea1}">
									</p:inputText>
									<p:message for="indirizzoLinea1Au" style="color:red;"/>
				
									<h:outputText value="#{msg.address_line_2}: "/>
									<p:inputText id="indirizzoLinea2Au" value="#{inserisciStudenteBean.studentInput.indirizzoAu.indirizzoLinea2}">
									</p:inputText>
									<p:message for="indirizzoLinea2Au" style="color:red;"/>
				
									<h:outputText value="#{msg.town}: "/>
									<p:inputText id="cittaAu" value="#{inserisciStudenteBean.studentInput.indirizzoAu.citta}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>
									</p:inputText>
									<p:message for="cittaAu" style="color:red;"/>
				
									<h:outputText value="#{msg.state}: "/>
									<p:inputText id="stato" value="#{inserisciStudenteBean.studentInput.indirizzoAu.stato}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="stato" style="color:red;"/>
					
									<h:outputText value="#{msg.post_code}: "/>
									<p:inputText id="postCode" value="#{inserisciStudenteBean.studentInput.indirizzoAu.postCode}">
										<f:validator validatorId="postCodeValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="postCode" style="color:red;"/>
				
									<h:outputText value="#{msg.country}: "/>
									<p:inputText id="paeseAu" value="#{inserisciStudenteBean.studentInput.indirizzoAu.paese}">
										<f:validator validatorId="genericNameValidator" style="color:red;"/>		
									</p:inputText>
									<p:message for="paeseAu" style="color:red;"/>
								</h:panelGrid>
							</fieldset>
									
							<p:commandButton ajax="false" process="@form" value="#{msg.submit}" action="#{inserisciStudenteBean.submit}"/>
							<p:growl id="growl" showDetail="false" showSummary="true"/>
					</fieldset>
					
				</p:panel>
				</h:form>
			</div>
			
			
		</ui:define>
	</ui:composition>



</body>
</html>
